<template>
  <a-modal v-model:visible.sync="store.state.user.add_status" title="设备工件信息新增" @ok="handleOk" okText="确认"
           cancelText="取消"
           @cancel="handle_cancel">
    <div class="row_box">
      <div class="column_box">
        <span>数采终端编号</span>
        <a-input v-model:value="formState.params.uEquipmentCode" placeholder="请输入数采终端编号"/>
      </div>
      <div class="column_box">
        <span>设备编号</span>
        <a-input v-model:value="formState.params.equipmentCode" placeholder="请输入工件名称"/>
      </div>
      <div class="column_box">
        <span>班次</span>
        <a-select
            v-model:value="formState.params.cId"
            style="width: 100%;margin-top: 1px"
            ref="select"
        >
          <a-select-option v-for="(item,index) in store.state.teamStore.team_list" :key="index" :value="item.cId">{{
              item.className
            }}
          </a-select-option>
        </a-select>
<!--        <a-input v-model:value="formState.params.partName" placeholder="请输入名称"/>-->
      </div>
      <div class="column_box">
        <span>负责人</span>
<!--        <a-input v-model:value="formState.params.partFNumber" placeholder="请输入工件图号"/>-->
        <a-select
            v-model:value="formState.params.userId"
            style="width: 100%;margin-top: 1px"
            ref="select"
        >
          <a-select-option v-for="(item,index) in store.state.user.user_list" :key="index" :value="item.userId">{{
              item.realName
            }}
          </a-select-option>
        </a-select>
      </div>
<!--      <div class="column_box">-->
<!--        <span>客户名称</span>-->
<!--        <a-input v-model:value="formState.params.cusName" placeholder="请输入客户名称"/>-->
<!--      </div>-->
      <!--      生产日期-->
<!--      <div class="column_box">-->
<!--        <span>生产日期</span>-->
<!--        <a-date-picker :default-value="formState.params.produceDate" v-model:value="formState.params.produceDate"-->
<!--                       show-time placeholder="请输入生产日期"/>-->
<!--      </div>-->
    </div>
  </a-modal>
</template>

<script>
import {defineComponent, reactive} from "vue";
import {useStore} from "vuex"
import {edit_p_class} from "@/api/device/device_person"
import {message} from "ant-design-vue";

export default defineComponent({
  name: "add_work",
  setup(props, context) {
    const formState = reactive({
      params: {
        "id": 0,
        "uEquipmentCode": "",
        "equipmentCode": "",
        "cId": null,
        "userId": null,
        "createTime": "",
        "updateTime": "",
        "createUserId": 0,
        "updateUserId": 0
      }
    })

    /**
     * 状态管理
     *
     * */
    const store = useStore()

    /**
     * 确认新增
     *
     * */
    const handleOk = async () => {
      store.commit("SET_ADD_ROLE", false)

      const res = await edit_p_class(formState.params)
      console.log(res)
      if (res.code === 1) {
        message.success("新增成功")
        formState.params = {}
        context.emit("re_flash:re_flash", "")
        return
      }
      message.success(res.message)

    }

    /**
     * 取消
     * */
    const handle_cancel = () => {
      store.commit("SET_ADD_ROLE", false)
    }

    return {
      formState,
      //状态管理
      store,
      // methods
      handleOk,
      handle_cancel
    }
  }
})
</script>

<style scoped lang="scss">

</style>
